/*
 * MKT:@(#) 64908-19001 A.03.40 68332 C CROSS COMPILER                   07Dec90                      
 * @(SUBID):$Source: /vsrc/vireo/include/RCS/m68332.h,v $ $Revision: 2.2 $
 */

/*
 * This include file defines table, tableN, tableU, tableUN, interpolate,
 * interpolateN, interpolateU, and interpolateUN which can be invoked to
 * generate the various forms of the 68332 table instruction.  It is
 * necessary to include this file for the table instruction to be used.
 */

/*
 * The following ALIAS pragmas and defines are part of the mechanism which
 * causes the eight functions defined here to be inline substituted when
 * this file is included, but not otherwise.  They cannot be inline
 * substituted when this file is not included because that would violate
 * the name space restrictions of the ANSI standard.
 */
#pragma	ALIAS    _SF___tableS ___tableS
#pragma	ALIAS    _SF___tableSN ___tableSN
#pragma	ALIAS    _SF___tableU ___tableU
#pragma	ALIAS    _SF___tableUN ___tableUN
#pragma	ALIAS    _SF_interpolateS _interpolateS
#pragma	ALIAS    _SF_interpolateSN _interpolateSN
#pragma	ALIAS    _SF_interpolateU _interpolateU
#pragma	ALIAS    _SF_interpolateUN _interpolateUN

#define __tableS _SF___tableS
#define __tableSN _SF___tableSN
#define __tableU _SF___tableU
#define __tableUN _SF___tableUN
#define interpolateS   _SF_interpolateS
#define interpolateSN _SF_interpolateSN
#define interpolateU   _SF_interpolateU
#define interpolateUN _SF_interpolateUN

/*
 * The following four macros are to be used for the table look up
 * version of the table instruction.  The array can usefully have
 * up to 256 elements whose size are either 1, 2, or 4 bytes.
 * The corresponding 68332 TBL[SU][N].[BWL] will be generated.
 */
#define tableS(array, x)   __tableS(array, x, sizeof(*array))
#define tableSN(array, x) __tableSN(array, x, sizeof(*array))
#define tableU(array, x)   __tableU(array, x, sizeof(*array))
#define tableUN(array, x) __tableUN(array, x, sizeof(*array))

#pragma SECTION PROG=libc

extern int __tableS(void *array, short x, unsigned int size);
extern int __tableSN(void *array, short x, unsigned int size);
extern unsigned int __tableU(void *array, short x, unsigned int size);
extern unsigned int __tableUN(void *array, short x, unsigned int size);

/*
 * The following four functions are to be used for the interpolate only
 * version of the table instruction.  A 68332 TBL[SU][N].L will be generated
 * when the code is optimized.
 */
extern int interpolateS(int y1, int y2, char x);
extern int interpolateSN(int y1, int y2, char x);
extern unsigned int interpolateU(unsigned int y1, unsigned int y2, char x);
extern unsigned int interpolateUN(unsigned int y1, unsigned int y2, char x);

#pragma SECTION UNDO
